home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / misc / sci / xspringies2.lha / xspringies / xspringies.txt < prev    next >
Encoding:
Text File  |  1995-04-23  |  22.4 KB  |  482 lines

  1. NAME
  2.        xspringies - a mass and spring simulation system for X
  3.  
  4. SYNTAX
  5.        xspringies [ options ]
  6.  
  7. DESCRIPTION
  8.        xspringies  is  a  simulator  which allows you to interac-
  9.        tively create and edit a system  of  masses  and  springs.
  10.        The  parameters  of  the  masses and springs (such as mass
  11.        elasticity and spring K) as well as those of the surround-
  12.        ing  system  (such  as  air  viscosity and gravity) can be
  13.        changed.
  14.        These systems can be loaded and saved into a file.
  15.  
  16.        I guess you could use xspringies for real work,  but  it's
  17.        really intended to be a time waster.
  18.  
  19. OPTIONS
  20.        -bg color
  21.               Specifies  the color of the window background.  The
  22.               default is black.
  23.  
  24.        -d dispname
  25.               Specifies the display screen  on  which  xspringies
  26.               displays  its window.  If the display option is not
  27.               specified, xspringies uses the display screen spec-
  28.               ified by your DISPLAY environment variable.
  29.  
  30.        -display dispname
  31.               This option is the same as the -d option.
  32.  
  33.        -fg color
  34.               Specifies  the foreground color of the window.  The
  35.               default is white.
  36.  
  37.        -geometry geom
  38.               Specifies the width, length, and  location  of  the
  39.               xspringies  window.   If the geometry option is not
  40.               specified, xspringies  uses  default  values.   The
  41.               geometry option has the format
  42.                    [=][widthxheight][+/-xoffset+/-yoffset].
  43.  
  44.        -hl color
  45.               Specifies  the  color  of  the button and selection
  46.               highlights in the window.   This  defaults  to  the
  47.               foreground color, or to green on color displays.
  48.  
  49.        -rv    Specifies that the foreground and background colors
  50.               be reversed.
  51.  
  52. CONTROLS
  53.          There are three types of controls (widgets)  in  xsprin-
  54.        gies.   There  are  push  buttons, checkboxes and sliders.
  55.  
  56. CMU Project Foobar        July 15, 1991                         1
  57.  
  58.        The push buttons and checkboxes act in the obvious manner.
  59.        If you click on them, they get activated.
  60.  
  61.          Sliders are a little more compilicated.  They consist of
  62.        a left arrow button, a right arrow button, and a text box.
  63.        The text box displays the current value.  Clicking on this
  64.        text box causes it to become highlighted.  All text  input
  65.        then goes to the text box.  After entering a value, return
  66.        accepts it, and escape cancels.
  67.          The value displayed can also be changed by pressing  the
  68.        arrow  buttons.   Using  the  Left mouse button causes the
  69.        value to be incremented or decremented by one  step.   The
  70.        Middle  mouse button is the same as the left mouse button,
  71.        but holding it down causes it to scan by  one  step  at  a
  72.        time.   The Right mouse button scans like the Middle mouse
  73.        button except that it scans 10 steps at a time.
  74.  
  75. EDITING MODES
  76.          There are three main modes  in  xspringies.   These  are
  77.        Edit, Mass and Spring.  In Edit mode, you can select, move
  78.        and throw objects.  In Mass mode, you can  create  masses.
  79.        In  Spring  mode,  you  can  create  springs and tug on an
  80.        object with a spring connected to the mouse.
  81.  
  82.        More specifically,
  83.  
  84.        Edit mode:
  85.               - Left mouse button selects objects.
  86.                 If you click on or near  an  object,  it  becomes
  87.               selected,  and all other objects become unselected.
  88.               If you hold down shift while clicking,  the  object
  89.               becomes  selected  (or unselected if it was already
  90.               selected), and all other objects remain the same.
  91.                 If you do not click near an object, dragging  the
  92.               mouse  causes  a selection box to appear.  Anything
  93.               within the selection box when the mouse is released
  94.               becomes  selected.   All  other masses become unse-
  95.               lected, unless the shift key was held down for  the
  96.               initial click.
  97.  
  98.               - Middle mouse button moves objects.
  99.                 All  selected  objects  move with the mouse.  The
  100.               masses are frozen in their positions after the ini-
  101.               tial  click.  They continue to move relative to the
  102.               mouse movement until the middle button is released.
  103.  
  104.               - Right mouse button throws objects.
  105.                 This acts the same way as moving objects with the
  106.               middle button, except for the fact that  the  mouse
  107.               velocity  is  transferred  to  all selected objects
  108.               when the right mouse button is released.
  109.                 Note: a good way to stop an object from moving is
  110.               to  simply  select  it  and  click  the right mouse
  111.  
  112. CMU Project Foobar        July 15, 1991                         2
  113.  
  114.               button.
  115.  
  116.        Mass mode:
  117.                 When you click with the mouse,  a  mass  appears.
  118.               The  mass takes on the values of the Mass and Elas-
  119.               ticity sliders.  The mass is placed when the  mouse
  120.               button is released.
  121.  
  122.        Spring mode:
  123.                 When you click with the mouse, if there is a mass
  124.               nearby, one end of a spring  is  connected  to  it.
  125.               The  other  end  of  the spring is connected to the
  126.               cursor until the mouse button is released.   If  no
  127.               mass  is  nearby  when  the spring is released, the
  128.               spring is discarded.  The new spring takes  on  the
  129.               values  of the Kspring and Kdamp sliders.  The rest
  130.               length of the spring is equal to the length of  the
  131.               spring when it was created.
  132.  
  133.               -  Left  mouse  button  adds  a  spring between two
  134.               masses while actively affecting the first mass.
  135.  
  136.               - Middle mouse button adds  a  spring  between  the
  137.               first  mass  and the cursor, actively affecting the
  138.               first mass.  The spring is discarded when the mouse
  139.               button is released.
  140.  
  141.               -  Right  mouse  button  adds  a spring between two
  142.               masses.  The first mass  is  not  affected  by  the
  143.               spring until the spring is in place after the mouse
  144.               is released.
  145.  
  146. OPERATION
  147.        Masses and Springs
  148.                 Accelerations  on  the  masses   are   calculated
  149.               according  to  gravity  (and other special forces),
  150.               viscous forces, and by  forces  from  the  springs.
  151.               When  a  mass collides with a wall, its velocity in
  152.               the direction of the wall is reversed.  The result-
  153.               ing  velocity is multipled by the Elasticity of the
  154.               mass.  So, an elasticity of 0.0 causes an inelastic
  155.               collision (it stops on the wall), and an elasticity
  156.               of 1.0 results in an elastic collision.
  157.                 If a mass is fixed, all forces on it are ignored.
  158.               It  simply does not move.  Think of it as a nail (a
  159.               really good one).
  160.                 The Mass and Elasticity of a mass can be  changed
  161.               by  selecting  the  mass and changing the values on
  162.               the corresponding sliders.  To make a mass fixed or
  163.               unfixed,  check  or uncheck the Fixed Mass checkbox
  164.               while the mass is selected.
  165.  
  166.                 A spring has three parameters associated with it.
  167.  
  168. CMU Project Foobar        July 15, 1991                         3
  169.  
  170.               Kspring,  Kdamp  and rest length.  The spring force
  171.               is calculated  as  follows  (according  to  Hooke's
  172.               law):
  173.                     F  =  -  Kspring  *  (length - rest length) -
  174.                         Kdamp * (velocity in spring direction)
  175.  
  176.                 To change the  Kspring  or  Kdamp  of  a  spring,
  177.               change the values of the sliders when the spring is
  178.               selected.  Pressing  the  Set  Rest  Length  button
  179.               changes the rest length of a selected spring to its
  180.               current length.
  181.  
  182.        Forces and sticky stuff
  183.                 There are  four  special  forces.   They  can  be
  184.               turned  on  and  off  by clicking their appropriate
  185.               box.  When highlighted, the force is on.   Each  of
  186.               these  forces has two parameters associated with it
  187.               (for example, Magnitude and Direction for gravity).
  188.               Only  one  forces's  parameters  are displayed at a
  189.               time (below the force buttons).   Which  particular
  190.               force  is  shown by a darker box around that force.
  191.               This force selector box is moved to  another  force
  192.               whenever a force is turned on.
  193.  
  194.                 Some  of  the forces are applied relative to some
  195.               specified origin, or  center  point.   By  default,
  196.               this  center point is the center of the screen.  It
  197.               can be changed to be any  one  particular  mass  by
  198.               selecting a single mass, and pushing the Set Center
  199.               button.  If no masses  are  selected,  the  current
  200.               center is changed to be the center of the screen.
  201.                 Center points are marked by a box around the cen-
  202.               ter mass.
  203.  
  204.                 There are four forces that can be  enabled.   The
  205.               first  one,  Gravity,  acts in the familiar manner.
  206.               It accelerates masses by  the  value  specified  by
  207.               Gravity in a direction specified by Direction.  The
  208.               Direction is measured in degrees, with 0.0  degrees
  209.               being down, increasing counter-clockwise.
  210.                 The  second  force  is  a  bit strange, and isn't
  211.               real.  Its a force which  attracts  the  center  of
  212.               mass  of  all  the objects toward the center point.
  213.               It has a Magnitude and a Damping coefficient.
  214.                 The third force is a  force  which  attracts  all
  215.               masses  toward  the center point.  This force has a
  216.               Magnitude and an Exponent associated with it.   The
  217.               Exponent is simply how the force relation works.  A
  218.               value of 2.0 means inverse-square force (the  force
  219.               is inversely proportional to the distance squared).
  220.               A value of 0.0 is a constant force  independent  of
  221.               position.   If the Magnitude of this force is nega-
  222.               tive, it becomes a repulsion force.
  223.  
  224. CMU Project Foobar        July 15, 1991                         4
  225.  
  226.                 The fourth  force  is  a  wall  repulsion  force.
  227.               Masses  are repelled by a force from each wall that
  228.               is on.  This force has  a  Magnitude  and  Exponent
  229.               associated with it.  The Exponent behaves similarly
  230.               to that of the third force.
  231.  
  232.                 For the most part, most everything obeys f =  ma.
  233.               The  only  exceptions  are  wall  bounces  and wall
  234.               stickiness.  Another unphysical aspect is found  in
  235.               some  of  the  special forces (the second and third
  236.               ones).  If a center point exists,  that  mass  does
  237.               not  receive  any  force response from other masses
  238.               due to the special force.  In  other  words,  these
  239.               two  special  forces  are  not  equal  and opposite
  240.               forces.  They're pretty much just unreal.
  241.  
  242.                 Viscosity is a viscous drag force which applies a
  243.               resistive force on the masses proportional to their
  244.               velocity.
  245.                 Stickiness is not a real force.  When a mass hits
  246.               a  wall, it loses part of its velocity component in
  247.               the direction of the wall  (in  an  amount  propor-
  248.               tional to the Stickiness).  If it loses all of this
  249.               component, it remains stuck to the wall.   It  will
  250.               remain  stuck  to  the  wall  until  a force (which
  251.               exceeds an amount proportional to  the  Stickiness)
  252.               pulls it off the wall.
  253.  
  254.        Numerics
  255.                 The  internals  of xspringies consist of a fourth
  256.               order  Runge-Kutta   (RK4)   differental   equation
  257.               solver.   Consult a Numerical Methods text for more
  258.               information.  The Time Step that is  used  by  this
  259.               solver (the dt) can be set using the slider.
  260.                 The  solver can be selectively made into an adap-
  261.               tive RK4 solver using the Adaptive Time Step check-
  262.               box.  An adaptive solver chooses the best time step
  263.               value according to an error calculation.  The error
  264.               is  not  allowed  to  exceed  the  Precision value.
  265.               Lower  precision  values  result  in  smaller  time
  266.               steps.  While this is more accurate, the simulation
  267.               runs slower.
  268.                 You will notice that some objects  will  tend  to
  269.               "blow  up" easily.  This is because the objects are
  270.               unstable,  or  are  sensitive  to  small  numerical
  271.               errors.  An object will tend to "blow up" less with
  272.               smaller time steps.  By using an  adaptive  solver,
  273.               the  simulation can be made more accurate only when
  274.               necessary.  This results in a  more  stable  system
  275.               which runs at a reasonable speed.
  276.  
  277.        Walls
  278.  
  279. CMU Project Foobar        July 15, 1991                         5
  280.  
  281.                 There  are  four  walls.   In  case  you  haven't
  282.               guessed by now, they are the top, left,  right  and
  283.               bottom  walls.   They  are  located  at  the window
  284.               boundaries; they move with window  resizes.   Indi-
  285.               vidual  walls can be enabled and disabled by check-
  286.               ing the corresponding checkboxes.
  287.  
  288.                 Walls are only one-way.  An  object  moving  from
  289.               the  screen toward a wall will bounce off the wall.
  290.               But an object moving from  off  screen  toward  the
  291.               screen will pass through the walls.
  292.  
  293.        Saving and Restoring State
  294.                 The  state of the world (at least for xspringies)
  295.               includes all of the masses and springs, as well  as
  296.               the  system  parameters.  By pushing the Save State
  297.               button, the current system  state  is  saved.    By
  298.               pushing  the  Restore  State  button the previously
  299.               saved system state is restored (if no previous save
  300.               was made, the initial state is used).
  301.  
  302.                 This  is  useful  for temporarily saving a system
  303.               configuration that you do not feel like setting  up
  304.               again (or saving to a file), that you might disturb
  305.               with experimentation.  If you  break  it,  you  can
  306.               Restore State any number of times you like.
  307.                 The Reset button resets xspringies to its initial
  308.               configuration.  All  the  masses  and  springs  are
  309.               removed,  and  the  default  system  parameters are
  310.               used.
  311.  
  312.        Saving and Loading Files
  313.                 The system state can be saved to and loaded  from
  314.               files.   By  pushing the Load File button, a previ-
  315.               ously saved file can be loaded.  This will load  up
  316.               all the masses and springs that were saved, as well
  317.               as  the  system  parameters.   Any  previous  state
  318.               before  the load is cleared.  Pushing the Save File
  319.               button saves this  information  in  the  designated
  320.               file.  The Insert File button is much like the Load
  321.               File button, except that the current state  is  not
  322.               cleared.   Instead, only the masses and springs are
  323.               loaded (the system paramaters are not changed), and
  324.               are  added  to  the  current  collection.    If  no
  325.               objects are selected when the Insert File button is
  326.               pressed,  then  all  the  objects  in  the file are
  327.               selected after they are loaded.
  328.  
  329.                 The filenames are entered  in  the  text  window,
  330.               which is located at the bottom right of the window.
  331.               For consistency,  the  filenames  should  terminate
  332.               with  ".xsp".  When a file is loaded or saved, this
  333.  
  334. CMU Project Foobar        July 15, 1991                         6
  335.  
  336.               extension is automatically added if  not  added  by
  337.               the user.
  338.                 By  default,  the  directory  which  contains the
  339.               xspringies files is present automatically.  If  the
  340.               environment  variable  SPRINGDIR  is  set, then the
  341.               default directory is changed to reflect it.
  342.                 If a file error occurs  (for  example,  the  file
  343.               does not exist), a beep is emitted.
  344.  
  345.        Other stuff
  346.                 The  Action  checkbox simply turns on and off the
  347.               animation.  With Action turned off, xspringies uses
  348.               up little CPU time.
  349.  
  350.                 The Show Springs checkbox controls whether or not
  351.               the springs are drawn.   If  there  are  a  lot  of
  352.               springs,  animation  may go faster with this option
  353.               on.  Sometimes an object will even look better with
  354.               only the masses.
  355.  
  356.                 When  placing  masses  or springs, objects can be
  357.               placed in a  gridlike  fashion  if  the  Grid  Snap
  358.               checkbox  is  enabled.   Masses  will  be separated
  359.               (vertically and horizontally) by the amount  speci-
  360.               fied by the Grid Snap slider.
  361.  
  362.                 When the Duplicate button is pushed, all selected
  363.               masses and springs are  duplicated.   The  copy  is
  364.               left in the same place, unselected.
  365.  
  366.                 By  pushing the Select All button, all masses and
  367.               springs are selected.
  368.  
  369.                 By pressing the Delete key, all selected  objects
  370.               are  deleted.   Note that if a mass is deleted, all
  371.               attached springs are also  deleted  (even  if  they
  372.               were not selected).
  373.  
  374.                 The  Quit  button  quits  the program.  This same
  375.               effect is found by pressing the Q key.
  376.  
  377. FILE FORMAT
  378.          The xspringies file format is human readable.  Each line
  379.        consists  of a four letter command string, followed by the
  380.        parameters for that command.  The file must start with the
  381.        command  "#1.0".   Each of the commands below is on a line
  382.        by itself.  There are no blank lines  allowed.   The  file
  383.        must end in a newline.
  384.  
  385.        The file consists of the following commands:
  386.             cmas <current Mass value>
  387.             elas <current Elasticity value>
  388.  
  389. CMU Project Foobar        July 15, 1991                         7
  390.  
  391.             kspr <current Kspring value>
  392.             kdmp <current Kdamp value>
  393.             fixm <boolean value for Fixed Mass>
  394.             shws <boolean value for Show Springs>
  395.             cent <mass id number of center mass>
  396.                If  there  is  no  center  mass  (i.e. - center of
  397.                screen is to be used), then the  value  of  -1  is
  398.                used.
  399.             frce        <force id number>        <boolean active>
  400.                  <parameter #1 value> <parameter #2 value>
  401.                The <force id number> sequence is as follows:
  402.                   0 - Gravity
  403.                   1 - Center of mass attraction force
  404.                   2 - Center attraction force
  405.                   3 - Wall repulsion force
  406.             visc <current Viscosity value>
  407.             stck <current Stickiness value>
  408.             step <current Time Step value>
  409.             prec <current Precision value>
  410.             adpt <boolean value for Adaptive Time Step>
  411.             gsnp <current Grid Snap value> <boolean enable>
  412.             wall  <boolean top>  <boolean left>   <boolean right>
  413.                  <boolean bottom>
  414.             mass        <mass id number>       <x position value>
  415.                  <y position value>            <x velocity value>
  416.                  <y velocity value>                  <mass value>
  417.                  <elasticity value>
  418.                For  each  mass,  the  <mass id number>  must   be
  419.                unique.   They do not need to be in any order.  If
  420.                a mass is fixed, then the  <mass value>  field  is
  421.                negated.
  422.             spng      <spring id number>      <mass #1 id number>
  423.                  <mass #2 id number>              <Kspring value>
  424.                  <Kdamp value> <rest length value>
  425.                For  each  spring,  the <spring id number> must be
  426.                unique.  They do not need to be in any order.  The
  427.                order  of the <mass id number>'s is not important.
  428.  
  429.          All values are floating point numbers.  All  id  numbers
  430.        are  positive  integers,  and  all boolean values are non-
  431.        zero/zero for True/False.  It is possible to feed  xsprin-
  432.        gies  bogus values.  It may produce interesting or amusing
  433.        side effects, but will most  likely  cause  an  object  to
  434.        explode or xspringies to crash.
  435.  
  436. AUTHOR
  437.        Douglas DeCarlo (dd2i+@andrew.cmu.edu)
  438.  
  439.        Please  send comments, suggestions, bug reports, bug fixes
  440.        and enhancements.
  441.  
  442.        With thanks to:
  443.               Elliott Evans
  444.  
  445. CMU Project Foobar        July 15, 1991                         8
  446.  
  447.                   Bitmap slave.
  448.  
  449.               Nathan Loofbourrow
  450.                   I bothered him  a  whole  lot  about  the  user
  451.                   interface.
  452.  
  453.               Drew Olbrich
  454.                   The blame for "stickiness" falls on him.
  455.  
  456.               Andy Witkin
  457.                   For  teaching  a  really great physically based
  458.                   modeling course at CMU.  Many ideas (both meth-
  459.                   ods and interface) came from that class.
  460.  
  461.               And the many other people at CMU who tested xsprin-
  462.               gies and made some of the neat demo files.
  463.  
  464. RESTRICTIONS
  465.        xspringies runs faster on a monochrome display than  on  a
  466.        color display (usually).
  467.  
  468.        You  probably  don't  want  to  run  xspringies  on a slow
  469.        machine or a machine which does slow  bit-blitting  opera-
  470.        tions.   Well, I guess you could... But you would be sorry
  471.        for even trying.
  472.  
  473.        Here is a good rule:  If xspringies isn't fun to use, then
  474.        your  machine is either too slow, or it is overloaded.  Or
  475.        maybe you just aren't a fun person.  :-)
  476.  
  477. SEE ALSO
  478.        xlife(6)
  479.  
  480. CMU Project Foobar        July 15, 1991                         9
  481.  
  482.